import concurrent.futures
import time


def worker(data):
    # 这里是线程要执行的任务
    time.sleep(2)
    result = data * 2
    return result


def callback(result):
    # 这里是在线程结束后执行的回调函数
    print("Result: ", result)


with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    future = executor.submit(worker, 10)
    future.add_done_callback(lambda fut: callback(fut.result()))
    print("===========")
print(123123)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    future = executor.submit(worker, 10)
    future.add_done_callback(lambda fut: callback(fut.result()))
    print("===========")
